//
//  KRCateTagsListController.m
//  cookBook
//
//  Created by kuroken on 16/1/30.
//  Copyright © 2016年 kuroken. All rights reserved.
//

#import "KRCateTagsListController.h"
#import "KRCateList.h"
#import "KRCateTags.h"
#import "KRCateTagController.h"

static NSString * const KRCateTagsListID = @"tagList";

@interface KRCateTagsListController ()

@end

@implementation KRCateTagsListController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = self.cateList.cate;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc
{
    NSLog(@"%s", __func__);
}


#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.cateList.cateTagArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:KRCateTagsListID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:KRCateTagsListID];
    }
    [cell.textLabel setText:self.cateList.cateTagArray[indexPath.row].tagName];
    [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    
    return cell;
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    KRCateTagController *cateTagVc = [[KRCateTagController alloc] init];
    cateTagVc.tagID = self.cateList.cateTagArray[indexPath.row].tagID;
    cateTagVc.title = self.cateList.cateTagArray[indexPath.row].tagName;
    [self.navigationController pushViewController:cateTagVc animated:YES];
}

@end